package com.example.web.repository;

import com.example.web.entity.Container;
import com.example.web.entity.Goods;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.math.BigDecimal;
import java.util.List;

public interface ContainerRepository extends JpaRepository<Container, Long> {

    @Query(value = "select cgrel.id from Container cgrel where cgrel.goods.id=:goodsId")
    List<Long> findAffectedContainer(@Param("goodsId") Long id);

    @Modifying
    @Query(value = "update t_container  c set c.price=:price where c.id=:id",nativeQuery = true)
    void updatePrice(@Param("id") Long id,@Param("price") Long price);
}
